package com.invoicing.Service;

import com.invoicing.dao.UserMapper;
import com.invoicing.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public User findUser(String name) {
        return userMapper.selectByName(name);
    }

    public int getCount(){ return userMapper.selectCount();}

    public int addUser(User user){ return userMapper.insertUser(user);}

    public User getRecent(){ return userMapper.getRecent();}

    public boolean userExit(String name){
        if(this.findUser(name)==null){
            return false;
        }
        else {
            return true;
        }
    }
    public boolean passwordConform(String name,String password){
        if(password.equals(this.findUser(name).getPassword())){
            return true;
        }
        return false;
    }
}
